<?php

class Application_Form_User extends Zend_Form
{

    public function init()
    {
        $this->setName('task');
        $this->setMethod('post');
        
        $id = new Zend_Form_Element_Hidden('id');
        $id->addFilter('Int');
        
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel('Потребителско име')
             ->setRequired(true)
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->addValidator('NotEmpty')
             ->addValidator('Alpha')
             ->addValidator('stringLength', false, array(3, 20))
            ;
             
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Парола')
             ->setRequired(true)
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->addValidator('NotEmpty')
             ->addValidator('Alnum')
             ->addValidator('stringLength', false, array(6, 20))
            ;
             
        $first_name = new Zend_Form_Element_Text('first_name');
        $first_name->setLabel('Име')
             ->setRequired(true)
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->addValidator('NotEmpty');
             
        $last_name = new Zend_Form_Element_Text('last_name');
        $last_name->setLabel('Фамилия')
             ->setRequired(true)
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->addValidator('NotEmpty');
             
        $position = new Zend_Form_Element_Text('position');
        $position->setLabel('Позиция')
             ->setRequired(true)
             ->addFilter('StripTags')
             ->addFilter('StringTrim')
             ->addValidator('NotEmpty');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Регистрация');
        
        $this->addElements(array(
            $id, $username, $password, $first_name, $last_name, $position, $submit
        ));
        
         $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'table', 'class' => 'form')),
            'Form'
        ));

        $this->setElementDecorators(array(
            'ViewHelper',
            'Errors',
            array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'value')),
            array('Label', array('tag' => 'td')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
        ));

        $submit->setDecorators(array(
            'ViewHelper',
            array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'value')),
            array(array('label' => 'HtmlTag'), array('tag' => 'td', 'class' => 'value', 'placement' => 'prepend')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
        ));
             
    }


}

